import java.sql.*;

public class demo1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        String url="jdbc:mysql://localhost:3306/db_view?useSSL=false&useUnicode=true&characterEncoding=utf8";
        String uname="root";
        String pwd="123456";
       Connection conn= DriverManager.getConnection(url,uname,pwd);
     Statement stmt= conn.createStatement();
     String sql="select *from dept";
        ResultSet rs=stmt.executeQuery(sql);
        while (rs.next()){
            int id=rs.getInt("deptno");
            String name=rs.getString("dname");
            String loc=rs.getString("loc");
            System.out.println(id+"\t"+name+"\t"+"loc");
        }

    }
}
